import java.util.HashSet;

public class Test {


    public boolean containsNearbyDuplicate(int[] nums, int k) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])){
                return true;
            }
            set.add(nums[i]);
            if (set.size() > k) {
                set.remove(nums[i-k]);
            }
        }
        return false;
    }

    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])){
                return true;
            }
            set.add(nums[i]);
        }
        return false;
    }

    public static void main1(String[] args) {
        BinarySearchTree binarySearchTree = new BinarySearchTree();

        int[] array = {30,20,50,40,60,65};

        for (int i = 0; i < array.length; i++) {
            binarySearchTree.insert(array[i]);
        }

//        BinarySearchTree.TreeNode search = binarySearchTree.search(70);
//        System.out.println(search.val);


        binarySearchTree.remove(50);
    }
}
